#pragma once
#include "type.h"
#include "encode.h"
/*
    --------------------------
	||  event   header      ||
	--------------------------
	||timestamp         4B  ||
	||typecode          1B  ||
	||serverid          4B  ||
	||eventlength       4B  ||
	||nextposition      4B  ||
	||flags             2B  ||
	--------------------------
*/
#ifndef LOGHEADER_H
#define LOGHEADER_H
#pragma pack(1)
typedef struct binlog_header : public code {
private:
	TIMESTAMP timestamp;
	U_WORD typecode;
	U_DDWORD serverid;
	U_DDWORD eventlength;
	U_DDWORD nextposition;
	U_DWORD flags;
public:
	void encode(PTL_BUFFER buffer);
	PTL_BUFFER decode();
	inline TIMESTAMP get_time_stamp() {
		return timestamp;
	}
	inline U_WORD get_type_code() {
		return typecode;
	}
	inline U_DDWORD get_server_id() {
		return serverid;
	}
	inline U_DDWORD get_event_len() {
		return eventlength;
	}
	inline U_DDWORD get_next_pos() {
		return nextposition;
	}
	inline U_DDWORD get_flags() {
		return flags;
	}

}TL_HEADER, *PTL_HEADER;
#pragma pack()
#endif // !LOGHEADER_H

